<template>
	<div>
		<van-tabs v-model="active" sticky>
			<van-tab title="首页">
				<sy @childMethod="getsongurlData"></sy>
			</van-tab>
			<van-tab title="前10歌手榜">
				<artists></artists>
			</van-tab>
			<van-tab title="精品歌单标签列表">
				<hot></hot>
			</van-tab>
		</van-tabs>
	</div>
</template>

<script>
	import Sy from '../sy.vue'
	import Artists from '../artists.vue'
	import Hot from '../hot.vue'
	export default {
		data() {
			return {
				active: 0
			};
		},
		components: {
			"sy": Sy,
			"artists": Artists,
			"hot": Hot
		},
		methods: {
			//获取歌曲播放url
			async getsongurlData(val) {
				let {
					data: ret
				} = await this.$http.get('/song/url?id=' + val.id)
				//console.log(ret)
				if (ret.code == 200) {
					//父页面数据
					let singernames = val.song.artists.map((item, index) => {
						return item.name;
					});
					singernames = singernames.join("、");
					this.$parent.currentSong.url = ret.data[0].url;
					this.$parent.currentSong.singer = singernames;
					this.$parent.currentSong.song = val.name;
				} else {
					this.$toast(ret.message);
				}
			}
		}
	}
</script>

<style lang="less" scoped>
</style>
